package com.hefei.garden.pojo;

/**
 * @author: devil
 * @Date: 2022/7/10 19
 * @Description: 返回实体封装类
 */
public class Result<T> {

    private int code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data) {
        return new Result<T>(data);
    }

    public static <T> Result<T> success() {
        return new Result<T>();
    }

    public static <T> Result<T> error(String msg) {
        return new Result<T>(msg);
    }

    public static <T> Result<T> error() {
        return new Result<T>("error");
    }

    private Result(T data) {
        this.code = 200;
        this.msg = "success";
        this.data = data;
    }

    private Result() {
        this.code = 200;
        this.msg = "success";
    }

    private Result(String msg) {
        this.code = 400;
        this.msg = msg;
    }

}

